/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#include "RendererGameComponent.h"

namespace XF
	{
	RendererGameComponent::RendererGameComponent(XF::Application *ownerApp, XF::OgreRenderer* renderer)
	: XF::SystemComponent(ownerApp), mRenderer(renderer)
	{
	}

	RendererGameComponent::~RendererGameComponent()
	{
	}

	bool RendererGameComponent::OnInitialise()
	{
		return this->SubscribeToMailingList(XF::MailingList::GRAPHICS_SUBSYSTEM);
	}

	bool RendererGameComponent::OnHandleMessage(const XF::Message &message)
	{
		if(message.Subject == XF::MessageSubject::PLEASE_SEND_RENDERER)
		{
			this->PostAMessage(
				message.SenderID,
				XF::MessageSubject::SENT_RENDERER,
				mRenderer);

			return true;
		}

		return false;
	}

	void RendererGameComponent::OnShutDown()
	{
		this->UnsubscribeFromMailingList(XF::MailingList::GRAPHICS_SUBSYSTEM);
	}
}